﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ViewDetails.aspx.cs" Inherits="ViewDetails" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="css/common.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        var xhr;
        window.onload = function () {
            xhr = createXmlHttp();
        }
        var ToSid =<%=model.SID %>

        function DoSupport(isSupport) {
            xhr.open("POST", "DoSupport.ashx", true);
            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhr.onreadystatechange = Watching;
            if (isSupport) {
            //点击了支持Button   在这里必须告诉处理异步的程序这里点了哪个按钮    所以这里做了标记
                xhr.send("sid="+<%=model. SID %>+"&isSup=1");
            }
            else {
            //点击了反对Button   在这里必须告诉处理异步的程序这里点了哪个按钮    所以这里做了标记
                xhr.send("sid="+<%=model. SID %>+"&isSup=0");
            }
        }
       
        function Watching() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    var text = xhr.responseText;
                    var textArr = text.split(",");
                    if(textArr[1]=="1")
                    {
                        gel("spanSup").innerHTML=textArr[0];
                    }
                    else
                    {
                        gel("spanDisSup").innerHTML=textArr[0];
                    }
                }
            }
        }
         
        function AddPL(){
        var data = "ToSid="+ToSid+"&txtContent="+gel("txtPinglun").value;
            xhr.open("POST","AddPinglun.ashx",true);
            xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            xhr.onreadystatechange=PWatching;
            xhr.send(data);
        }

        function PWatching(){
            if(xhr.readyState==4){
                if(xhr.status==200) {
                    var text = xhr.responseText;
                    if(text=="OK")
                    {
                            var plTable = gel("plTable");
                            var newRow = plTable.insertRow(plTable.rows.length);
                            var newNameCell = newRow.insertCell();
                            var newContentCell = newRow.insertCell();
                            newNameCell.innerHTML =gel("txtPinglun").value;
                            newContentCell.innerHTML="<%=GetNowUserName() %>"+" 说";
                    }
                  else{
                            alert(xhr.status);
                  }
                }
            }
        }
    </script>
</head>
<body>
<center>
    <table id="title" border="0">
            <tr>
                <td>查看学员信息</td>
            </tr>
		</table>
		<table id="content" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="30%" class="descTd">用户名： </td>
                <td width="35%" ><%=model.SLoginName %></td>
                <td class="alertCol"></td>
            </tr>
            <tr>
                <td class="descTd">中文名：</td>
                <td ><%=model.SCnName %></td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="descTd">班&nbsp;&nbsp;&nbsp;级：</td>
                <td align="left" class="rdoTd"><%=model.SClass.CName %></td>
                <td></td>
            </tr>
            <tr>
                <td class="descTd">性&nbsp;&nbsp;&nbsp;别：</td>
                <td align="left" style="padding-left:10px;" class="rdoTd"><%=model.SGender?"男":"女" %></td>
                <td></td>
            </tr>
			<tr>
                <td class="descTd">电&nbsp;&nbsp;&nbsp;话：</td>
                <td ><%=model.STel %></td>
                <td >
                </td>
            </tr>
            <tr>
                <td class="descTd">支持人数：<span id="spanSup"><%=model.SSupport %></span></td>
                <td >反对人数：<span id="spanDisSup"><%=model.SDisSupport %></span></td>
                <td >
                </td>
            </tr>
			<tr>
            <td>
            </td>
                <td>
                    <input type="button" id="btnYes" value="顶" onclick="DoSupport(true)" class="btnC" />
                    <input type="button" id="btnNo" value="踩" onclick="DoSupport(false)" class="btnC" />
                </td>
                <td></td>
            </tr>
        </table>
         <hr />
        评论信息：
        <table id="plTable" style="width:600px; border:1px solid #000;" border="1" cellpadding="0" cellspacing="0">
            <tr>
                <td width="30%" class="descTd">用户名</td>
                <td>内容</td>
            </tr>
            <%=GetPinglun() %>
        </table>
        <br />
        <hr />
        <table style="width:600px; border:1px solid #000; text-align:left;" border="1" cellpadding="0" cellspacing="0">
            <tr>
                <td>发布内容：</td>
            </tr>
            <tr>
                <td>
                    <textarea id="txtPinglun" cols="40" rows="10"></textarea>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" onclick="AddPL()"  id="btnPinglun" value="发布评论" />
                </td>
            </tr>
        </table>
        </center>
</body>
</html>
